package com.eascs.admin.o2o.detail.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.eascs.admin.common.dao.BaseReportDao;
import com.eascs.admin.o2o.detail.entity.OaPay;
import com.eascs.app.dao.PageResult;
import com.eascs.app.dao.SqlPageQuery;

/**
 * 
 * 查询数据中心
 *
 */
@Repository
public class DataCenterDao extends BaseReportDao {
	
	/**
	 * 逾期信息
	 * @param loanapplyNo
	 * @return
	 */
	public PageResult<Object[]> queryOverdue(String billCode){
		String sql="SELECT T.BILLCODE,T.OVERDUE_PRINCIPAL,T.OVERDUE_INTEREST,T.STATUS,T.PENALTY_INTEREST,T.DEFAULT_AMOUT,T.DISPOSAL_AMOUNT,T.DISPOSAL_DATE "
				+ "FROM BASIC_INFORMATION_OVERDUE T WHERE T.IS_NEW='Y' AND T.BILLCODE=? AND T.STATUS IN('1','2','3','4')";
		SqlPageQuery<Object[]> sqlPageQuery = new SqlPageQuery<>(Object[].class, 10, 0);
		sqlPageQuery.addParam(billCode);
		sqlPageQuery.setQuerySql(sql);
		return this.findDataWithPage(sqlPageQuery);
	}
	/**
	 * 银行申报 逾期信息
	 * @param loanapplyNo
	 * @return
	 */
	public PageResult<Object[]> queryOverduelist(List<Object> billCodes){
		StringBuffer sql=new StringBuffer("SELECT T.BILLCODE,T.OVERDUE_PRINCIPAL,T.OVERDUE_INTEREST,T.STATUS,T.PENALTY_INTEREST,T.DEFAULT_AMOUT,T.DISPOSAL_AMOUNT,T.DISPOSAL_DATE "
				+ "FROM BASIC_INFORMATION_OVERDUE T WHERE T.IS_NEW='Y'  AND T.STATUS IN('1','2','3','4') AND T.BILLCODE IN(");
		StringBuffer sf=new StringBuffer("?");
		if(null!=billCodes && !billCodes.isEmpty()){
			for (int i = 1; i < billCodes.size(); i++) {
				sf.append(",?");
			}
		}
		sql.append(sf.toString());
		sql.append(")");
		SqlPageQuery<Object[]> sqlPageQuery = new SqlPageQuery<>(Object[].class, 10, 0);
		sqlPageQuery.addParams(billCodes);
		sqlPageQuery.setQuerySql(sql.toString());
		return this.findDataWithPage(sqlPageQuery);
	}
	/**
	 * 代偿信息（垫付）
	 * @param billCode
	 * @return
	 */
	public OaPay queryOaPay(String billCode){
//		String sql="SELECT T.BILL_CODE,T.LOAN_AMOUNT,T.COMPENSATORY_AMOUNT FROM BASIC_INFORMATION_AFTER_LOAN T "
//				+ "WHERE T.BILL_CODE=? AND T.REPAY_STATUS='OVER_3' AND T.SOURCE_TYPE='0' ";
		return null;
	}
}

